﻿using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Collections.Generic;
using UIDesigner.Designers;
using SharedClasses;
using System.ComponentModel.Design;
using DDW;
using AFSharedLibrary;
using UIDesigner.FieldHandlers;
using System.IO;
using System.Reflection;
using UIDesigner.FieldHandlers.Bases;
using UIDesigner.DesignContainers.Bases;
using UIDesigner.Editors;

namespace UIDesigner.DesignContainers
{
    [Designer(typeof(Design.ObjectTreeViewDesigner))]
    public class ObjectTreeView : BaseObjectControl
    {
        private TreeView m_ctrlTreeView;
        private Construct m_objConstruct;

        public override void HandleSurfaceProperties(DynamicEnumType objDynamicEnumType)
        {
            throw new NotImplementedException();
        }

        [Browsable(false)]
        public override Construct BusinessObject
        {
            get
            {
                return m_objConstruct;
            }
        }

        [Category("Appearance")]
        public TreeView TreeView
        {
            get 
            { 
                return m_ctrlTreeView; 
            }
        }

        [Browsable(false)]
        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
                Rebuild();
            }
        }

        public ObjectTreeView()
        {
        }

        protected override void OnLoad(object sender)
        {
            Rebuild();
        }

        public override void OnFlush()
        {

        }

        private void Rebuild()
        {
            this.Controls.Clear();
            m_ctrlTreeView = new TreeView();

            this.Controls.Add(m_ctrlTreeView);
            m_ctrlTreeView.Dock = DockStyle.Fill;

            BaseFieldHandler.RequestType += new Handlers.RequestTypeHandler(BaseFieldHandler_RequestType);

            StatusBar.Text = "Waiting for user configuration";
        }
    }
}
